#include <csugl.h>

#include <vector>
#include <array>

struct Square;

struct GizmosRenderer {
    static void init();

    static void begin();

    static void submit(csugl::Ref<csugl::Shader> shader, csugl::Ref<Square> square);

    static void end();

private:
    struct BatchContainer;
    struct RenderBatch {
        static const size_t MAX_VERTEX_NUM;
        static const size_t MAX_INDEX_NUM;
        csugl::Ref<csugl::VertexArray> vao;
        size_t indices_offset;
        size_t vertices_top;
        RenderBatch(const BatchContainer* container);
    };
    struct BatchContainer {
        static const size_t MAX_BATCH_SIZE;
        csugl::Ref<csugl::VertexBuffer> vbo;
        // MAX Batch Nums
        std::vector<RenderBatch> batchs; // dynamic
        size_t batch_top;
        BatchContainer();
    };
    std::vector<csugl::Ref<BatchContainer>> containers; // dynamic
    size_t container_top;
    
    void flush();

};